package com.cqwshzj.bizjob.simple;/**
 * @Description:
 * @Auther: Huang Zhijin
 * @Version: 1.0.0
 * @Date: 2021/4/8 19:06
 */

import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.TimeUnit;

/**
 *
 * 〈〉
 *
 * @author Huang Zhijin
 * @create 2021/4/8
 * @since 1.0.0
 */
public class HzjSimpleJob implements SimpleJob {

	private static final Logger log = LoggerFactory.getLogger(HzjSimpleJob.class);

	@Override
	public void execute(ShardingContext shardingContext) {
		log.info(" job start. shardingItem=[{}] shardingParameter=[{}] jobParameter=[{}] taskId=[{}].",shardingContext.getShardingItem(), shardingContext.getShardingParameter(), shardingContext.getJobParameter(), shardingContext.getTaskId());


//		doExecute(shardingContext);
	}



//	@Override
	public void doExecute(ShardingContext shardingContext) {
		int time = 2;
		for (int i = 0; i < time; i++) {
			try {
				log.info( "[{}] job running . count=[{}]  ",shardingContext.getShardingItem(),i);
				TimeUnit.SECONDS.sleep(1);
			} catch (InterruptedException e) {
				log.error(e.getMessage(),e);
			}
		}
	}
}
